package com.qf.lanzhou.blog.api.dao.Impl;

import com.qf.lanzhou.blog.api.dao.CollectArticlepsDao;
import com.qf.lanzhou.blog.api.pojo.entity.Article;
import com.qf.lanzhou.blog.api.pojo.entity.Collect;
import com.qf.lanzhou.blog.api.util.DruidUtil;
import org.apache.commons.dbutils.*;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * @Author jian
 * @Date 2020/12/21 14:14
 * @JDK 1.8
 * @Version 1.0
 */
public class CollectArticlepsDaoimpl implements CollectArticlepsDao {
    private QueryRunner queryRunner = new QueryRunner(DruidUtil.getDataSource());
    @Override
    public List<Article> selectcollectArticleps(String userId) {
        String sql="SELECT * from t_article as a right join t_collect as c on a.article_id=c.article_id where user_id=? and collect_status=1";
        BeanProcessor bean = new GenerousBeanProcessor();
        RowProcessor processor = new BasicRowProcessor(bean);
        try {
            return queryRunner.query(sql,new BeanListHandler<Article>(Article.class),userId);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return null;
    }
}
